_realname=talkatu
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.1.0.r419.ebabd7682683
pkgrel=1
pkgdesc="Gtk+ widgets for chat software (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url='https://keep.imfreedom.org/talkatu/talkatu'
license=('GPL2')
depends=(
  "${MINGW_PACKAGE_PREFIX}-gtk3"
  "${MINGW_PACKAGE_PREFIX}-glib2"
  "${MINGW_PACKAGE_PREFIX}-gumbo-parser"
  "${MINGW_PACKAGE_PREFIX}-cmark"
  "${MINGW_PACKAGE_PREFIX}-gspell"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-meson"
  "${MINGW_PACKAGE_PREFIX}-ninja"
  "${MINGW_PACKAGE_PREFIX}-pkg-config"
  "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
  "${MINGW_PACKAGE_PREFIX}-gtk-doc"
  "${MINGW_PACKAGE_PREFIX}-vala"
  "${MINGW_PACKAGE_PREFIX}-cc"
  "mercurial"
)
_commit="ebabd7682683"
source=("hg+https://keep.imfreedom.org/talkatu/talkatu#revision=${_commit}")
sha256sums=('SKIP')

prepare() {
  cd "${srcdir}"/${_realname}
}

pkgver() {
  cd "${srcdir}"/${_realname}
  printf "0.1.0.r%s.%s" "$(hg identify -n -r "${_commit}")" "$(hg identify -i -r "${_commit}")"
}

build() {
  mkdir -p build-${MINGW_CHOST} && cd build-${MINGW_CHOST}

  MSYS2_ARG_CONV_EXCL="--prefix=" \
  meson \
    --prefix="${MINGW_PREFIX}" \
    --wrap-mode=nodownload \
    --auto-features=enabled \
    --buildtype=plain \
    ../${_realname}

  meson compile
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"

  DESTDIR="${pkgdir}" meson install

  install -Dm644 "${srcdir}/${_realname}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
